package chzhenjia.learn.androidcode.four;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;

import com.loopj.android.image.SmartImageTask;
import com.loopj.android.image.SmartImageView;

import chzhenjia.learn.androidcode.R;

public class SmartImageActivity extends AppCompatActivity implements View.OnClickListener {

    private SmartImageView ivNetwork;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_smart_image);
        ivNetwork = (SmartImageView) findViewById(R.id.iv_network);
        Button btnLoadImage = (Button) findViewById(R.id.btn_load_image);
        btnLoadImage.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {   
        switch (v.getId()) {
            case R.id.btn_load_image:
                loadImage();
                break;
        }
    }

    private void loadImage() {
        ivNetwork.setImageUrl("http://192.168.12.164/test/2.jpg", new SmartImageTask.OnCompleteListener() {
            @Override
            public void onComplete() {
                System.out.println("onComplete run ...... ");
            }
        });
    }
}
